#include "siftfeaturedetector.h"

#include <stdio.h>
#include <iostream>

#include <QMessageBox.h> // for debug only
#include <QString.h> // for debug only

using namespace std;

/******************************************************/
SiftFeatureDetector::SiftFeatureDetector()
{
	// Set non-default parameters to reduce number of detections
	const double threshold = 0.2 / cv::SIFT::CommonParams::DEFAULT_NOCTAVE_LAYERS / 2.0;
	const double edge_threshold = 5.0;
	_feature_detector = new cv::SiftFeatureDetector(threshold, edge_threshold);
	_feature_extractor = cv::DescriptorExtractor::create("SIFT");
}

/******************************************************/
SiftFeatureDetector::~SiftFeatureDetector()
{}

/******************************************************/
void SiftFeatureDetector::extract(
	const cv::Mat& input, 
	std::vector<cv::KeyPoint>& key_points,
	cv::Mat& descriptors)
{
	// Detect SIFT kepypoints
	_feature_detector->detect(input, key_points);

	_feature_extractor->compute(input, key_points, descriptors);
}
